package wtc.stu.test;

import java.util.Scanner;

import wtc.stu.dao.StuLgoin;
import wtc.stu.entity.StuEntity;
import wtc.stu.method.*;

public class MyMain {
    public static void main(String[] args) {
        System.out.println("欢迎使用学生信息管理系统，请登录： ");
        //第二步：用用户登陆
        //定义一个从键盘输入的工具对象
        Scanner sa = new Scanner(System.in);
        System.out.println("请输入账号：");
        String uname = sa.next();
        System.out.println("请输入密码：");
        String upsw = sa.next();
        //第三步：登陆判断
        //第一小步：把用用户填写 的账号和密码封装起来
        StuEntity user = new StuEntity();
        user.setUname(uname);
        user.setUpsw(upsw);
        //第二小步：调用数据处理
        StuLgoin dao03 = new StuLgoin();
        int count = dao03.getLogin(user);//把封装好的对象丢过去
        if (count > 0) {
        StuMethod method = new StuMethod();
        method.methodPrint();
        int flag = sa.nextInt();
        GradeImpl gradeImpl = new GradeImpl();
        DepartmentImpl departmentImpl = new DepartmentImpl();
        ClassImpl classImpl = new ClassImpl();
        MajorImpl majorImpl = new MajorImpl();
        StuImpl stuImpl = new StuImpl();
        TeacherImpl teacherImpl = new TeacherImpl();
        ScoreImpl scoreImpl = new ScoreImpl();
        IntegratedQueryImpl integratedQueryImpl = new IntegratedQueryImpl();
            switch (flag) {
                case 1:
                    method.methodPrintGrade();
                    int num01 = sa.nextInt();
                    switch (num01) {
                        case 01:
                            gradeImpl.methodSelect();
                            break;
                        case 02:
                            gradeImpl.methodInsert();
                            break;
                        case 03:
                            gradeImpl.methodUpdate();
                            break;
                    }
                    break;

                // 系别表
                case 2:
                    method.methodPrintDepartment();
                    int num02 = sa.nextInt();
                    switch (num02) {
                        case 01:
                            departmentImpl.methodSelect();
                            break;
                        case 02:
                            departmentImpl.methodInsert();
                            break;
                        case 03:
                            departmentImpl.methodUpdate();
                            break;
                    }
                    break;

                // 班级表
                case 3:
                    method.methodPrintClass();
                    int num03 = sa.nextInt();
                    switch (num03) {
                        case 01:
                            classImpl.methodSelect();
                            break;
                        case 02:
                            classImpl.methodInsert();
                            break;
                        case 03:
                            classImpl.methodUpdate();
                            break;
                    }
                    break;

                // 专业表
                case 4:
                    method.methodPrintMajor();
                    int num04 = sa.nextInt();
                    switch (num04) {
                        case 01:
                            majorImpl.methodSelect();
                            break;
                        case 02:
                            majorImpl.methodInsert();
                            break;
                        case 03:
                            majorImpl.methodUpdate();
                            break;
                    }
                    break;
                // 学生表
                case 5:
                    method.methodPrintStu();
                    int num05 = sa.nextInt();
                    switch (num05) {
                        case 01:
                            stuImpl.methodSelect();
                            break;
                        case 02:
                            stuImpl.methodInsert();
                            break;
                        case 03:
                            stuImpl.methodUpdate();
                            break;
                        case 04:
                            stuImpl.methodDelete();
                            break;
                    }
                    break;
                // 教师表
                case 6:
                    method.methodPrintTeacher();
                    int num06 = sa.nextInt();
                    switch (num06) {
                        case 01:
                            teacherImpl.methodSelect();
                            break;
                        case 02:
                            teacherImpl.methodInsert();
                            break;
                        case 03:
                            teacherImpl.methodUpdate();
                            break;
                    }
                    break;
                // 分数表
                case 7:
                    method.methodPrintScore();
                    int num07 = sa.nextInt();
                    switch (num07) {
                        case 01:
                            scoreImpl.methodSelect();
                            break;
                        case 02:
                            scoreImpl.methodInsert();
                            break;
                        case 03:
                            scoreImpl.methodUpdate();
                            break;
                        case 04:
                            scoreImpl.methodDelete();
                            break;
                    }
                    break;
                // 综合查询
                case 8:
                    method.printIntegratedQuery();
                    int num08 = sa.nextInt();
                    switch (num08) {
                        case 01:
                            integratedQueryImpl.methodSelect();
                            break;
                        case 02:
                            integratedQueryImpl.methodSelectScore();
                            break;
                    }
                    break;
                default:
                    System.out.println("退出系统！");
                    break;
            }
        } else {
            System.out.println("登录失败，退出系统！");
        }
    }
}
